package ac.github.os.internal.core.action.player

import ac.github.os.internal.core.action.IEntityAction
import ac.github.os.internal.core.config.StringConfig
import ac.github.os.internal.core.config.get
import ac.github.os.internal.core.objective.EntityObjective
import ac.github.os.internal.session.Cache
import ac.github.os.internal.session.Session
import taboolib.common.platform.Awake

@Awake
class TellAction : IEntityAction {

    override fun onExecute(session: Session, cache: Cache, config: StringConfig) {
        config.get<String>("value", single = true)?.apply {
            cache.objectives.filterIsInstance<EntityObjective>().forEach {
                it.entity.sendMessage(this)
            }
        }
    }

    override val namespace: String
        get() = "player:tell"

}